//
//  JoinHomeView.m
//  location
//
//  Created by Dongxiang Xu on 2025/9/10.
//

#import "JoinHomeView.h"
#import "UIImageView+WebCache.h"
#import <QuartzCore/QuartzCore.h>

@interface JoinHomeView ()

@property (nonatomic,strong) UITextField *textField;
@property (nonatomic,strong) UIButton *join;
@property (nonatomic,strong) UIView *infoView;

@end

@implementation JoinHomeView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.masksToBounds = YES;
        [self initView];
    }
    return self;
}

- (void)initView
{
    UIView *infoView = [[UIView alloc] initWithFrame:CGRectMake(12, SCREEN_HEIGHT, SCREEN_WIDTH-24, 378)];
    self.infoView = infoView;
    infoView.layer.masksToBounds = YES;
    [infoView.layer setCornerRadius:40];
    infoView.backgroundColor = RealWhiteColor;
    [self addSubview:infoView];
    
    UIButton *close = [[UIButton alloc] initWithFrame:CGRectMake(infoView.width-46, 16, 30, 30)];
    [close setImage:[UIImage imageNamed:@"map_close"] forState:UIControlStateNormal];
    [infoView addSubview:close];
    [[close rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        [UIView animateWithDuration:0.3 animations:^{
            infoView.y = SCREEN_HEIGHT;
            self.backgroundColor = [RealBlackColor colorWithAlphaComponent:0];
        } completion:^(BOOL finished) {
            [self removeFromSuperview];
        }];
    }];
    
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 78, infoView.width, 438)];
    [scrollView setContentSize:CGSizeMake(infoView.width*2, 0)];
    scrollView.scrollEnabled = NO;
    [infoView addSubview:scrollView];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, infoView.width-40, 28)];
    titleLabel.font = MEDIUM_FONT(20);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = @"输入邀请码";
    titleLabel.textColor = RealBlackColor;
    [scrollView addSubview:titleLabel];
    
    for (int i=0; i<5; i ++) {
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake((infoView.width-250)/2+i*52, CGRectGetMaxY(titleLabel.frame)+28, 42, 56)];
        button.tag = 100+i;
        button.layer.masksToBounds = YES;
        [button.layer setCornerRadius:16];
        if (i==0) {
            button.backgroundColor = NormalMainColor;
        }else{
            button.backgroundColor = LightBGColor;
        }
        [button setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        button.titleLabel.font = RUBIK_BOLD_FONT(24);
       
        [scrollView addSubview:button];
        [[button rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            [self.textField becomeFirstResponder];
        }];
    }
    
    UILabel *subTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(titleLabel.frame)+94, infoView.width, 18)];
    subTitle.font = DEFAULT_FONT(14);
    subTitle.textAlignment = NSTextAlignmentCenter;
    subTitle.textColor = [GraryHeavyLightColor colorWithAlphaComponent:0.6];
    subTitle.text = @"向创建者询问邀请码";
    [scrollView addSubview:subTitle];
        
    _textField = [[UITextField alloc] initWithFrame:CGRectMake(2*SCREEN_WIDTH, 0, 100, 10)];
    _textField.keyboardType = UIKeyboardTypeDefault;
    _textField.autocorrectionType = UITextAutocorrectionTypeNo;
    _textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    [_textField becomeFirstResponder];
    _textField.tintColor = BlackColor;
    [_textField addTarget:self action:@selector(textChangeEvent:) forControlEvents:UIControlEventEditingChanged];
    [self addSubview:_textField];
    
    _join = [[UIButton alloc] initWithFrame:CGRectMake(20, CGRectGetMaxY(subTitle.frame)+28, infoView.width-40, 54)];
    _join.layer.masksToBounds = YES;
    [_join.layer setCornerRadius:27];
    _join.backgroundColor = GraryMiddleColor;
    [_join setTitle:@"加入家庭" forState:UIControlStateNormal];
    [_join.titleLabel setFont:MEDIUM_FONT(16)];
    [_join setTitleColor:RealWhiteColor forState:UIControlStateNormal];
    _join.userInteractionEnabled = NO;
    [scrollView addSubview:_join];
    [[_join rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        [self.textField resignFirstResponder];
 
        NSMutableDictionary *param = [NSMutableDictionary dictionary];
        [param setValue:self.textField.text forKey:@"invitedCode"];
        CryptoHTTPKit *manager = [[CryptoHTTPKit alloc] init];
        [manager encryptedPOST:@"/system/group/getgroupuserbycode"
        parameters:param
        success:^(NSDictionary *responseObject) {
            if ([responseObject[@"code"] integerValue]==200) {
                [UIView animateWithDuration:0.3 animations:^{
                    [scrollView setContentOffset:CGPointMake(infoView.width, 0)];
                    [infoView setFrame:CGRectMake(12, SCREEN_HEIGHT-544, SCREEN_WIDTH-24, 516)];
                }];
                
                UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(infoView.width+20, 0, infoView.width-40, 28)];
                titleLabel.font = MEDIUM_FONT(20);
                titleLabel.textAlignment = NSTextAlignmentCenter;
                titleLabel.text = @"即将加入";
                titleLabel.textColor = RealBlackColor;
                [scrollView addSubview:titleLabel];
                
                UILabel *subTitle = [[UILabel alloc] initWithFrame:CGRectMake(titleLabel.x, titleLabel.maxY+4, titleLabel.width, 26)];
                subTitle.font = MEDIUM_FONT(16);
                subTitle.textAlignment = NSTextAlignmentCenter;
                subTitle.text = [NSString stringWithFormat:@"“%@”",responseObject[@"data"][@"groupInfo"][@"name"]];
                subTitle.textColor = RealBlackColor;
                [scrollView addSubview:subTitle];
                
                UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(infoView.width+(infoView.width-120)/2, subTitle.maxY+28, 120, 120)];
                img.image = [UIImage imageNamed:@"join_home"];
                [scrollView addSubview:img];
                
                UILabel *memberLabel = [[UILabel alloc] initWithFrame:CGRectMake(titleLabel.x, img.maxY+28, titleLabel.width, 18)];
                memberLabel.font = DEFAULT_FONT(14);
                memberLabel.textAlignment = NSTextAlignmentCenter;
                memberLabel.textColor = [GraryHeavyLightColor colorWithAlphaComponent:0.6];
                memberLabel.text = @"家庭成员在等你";
                [scrollView addSubview:memberLabel];
                
                UIView *memberView = [[UIView alloc] initWithFrame:CGRectMake(0, memberLabel.maxY+20, 0, 42)];
                [scrollView addSubview:memberView];
                
                
                if ([responseObject[@"data"][@"userInfo"] count]>3) {
                    for (int i = 0; i < 3; i ++) {
                        UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(i*64, 0, memberView.height, memberView.height)];
                        img.layer.masksToBounds = YES;
                        [img.layer setCornerRadius:12];
                        [img sd_setImageWithURL:[NSURL URLWithString:responseObject[@"data"][@"userInfo"][i][@"avatar"]]];
                        [memberView addSubview:img];
                        
                        if (i==2) {
                            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(img.maxX+19, 0, 20, memberView.height)];
                            label.font = MEDIUM_FONT(15);
                            label.textColor = NormalMainColor;
                            label.text = [NSString stringWithFormat:@"+%lu",(unsigned long)([responseObject[@"data"][@"userInfo"] count]-3)];
                            [memberView addSubview:label];
                            
                            [memberView setFrame:CGRectMake(infoView.width+(infoView.width-label.maxX)/2, memberLabel.maxY+20, label.maxX, 42)];
                        }
                    }
                }else{
                    for (int i = 0; i < [responseObject[@"data"][@"userInfo"] count]; i ++) {
                        UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(i*64, 0, memberView.height, memberView.height)];
                        img.layer.masksToBounds = YES;
                        [img.layer setCornerRadius:12];
                        [img sd_setImageWithURL:[NSURL URLWithString:responseObject[@"data"][@"userInfo"][i][@"avatar"]]];
                        [memberView addSubview:img];
                        
                        if (i==([responseObject[@"data"][@"userInfo"] count]-1)) {
                            [memberView setFrame:CGRectMake(infoView.width+(infoView.width-img.maxX)/2, memberLabel.maxY+20, img.maxX, 42)];
                        }
                    }
                }
                
                UIButton *join = [[UIButton alloc] initWithFrame:CGRectMake(infoView.width+20, CGRectGetMaxY(memberView.frame)+40, infoView.width-40, 54)];
                join.layer.masksToBounds = YES;
                [join.layer setCornerRadius:27];
                join.backgroundColor = NormalMainColor;
                [join setTitle:@"加入" forState:UIControlStateNormal];
                [join.titleLabel setFont:MEDIUM_FONT(16)];
                [join setTitleColor:RealWhiteColor forState:UIControlStateNormal];
                [scrollView addSubview:join];
                [[join rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
                    NSMutableDictionary *param = [NSMutableDictionary dictionary];
                    [param setValue:self.textField.text forKey:@"invitedCode"];
                    CryptoHTTPKit *manager = [[CryptoHTTPKit alloc] init];
                    [manager encryptedPOST:@"/system/group/addgroupuserbycode"
                    parameters:param
                    success:^(NSDictionary *responseObject) {
                        if ([responseObject[@"code"] integerValue]==200) {
                            [UIView animateWithDuration:0.3 animations:^{
                                infoView.y = SCREEN_HEIGHT;
                                self.backgroundColor = [RealBlackColor colorWithAlphaComponent:0];
                            } completion:^(BOOL finished) {
                                [self removeFromSuperview];
                                [XDXShareInstance shareInstance].ReloadGroupListFlag = YES;
                            }];
                        }else{
                            CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.x"];
                            shakeAnimation.values = @[@0, @-10, @10, @-10, @10, @-5, @5, @-5, @5, @0];
                            shakeAnimation.duration = 0.5;
                            shakeAnimation.repeatCount = 1;
                            shakeAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
                            [infoView.layer addAnimation:shakeAnimation forKey:@"shake"];
                        }
                        [[HCToast shareInstance] showToast:responseObject[@"msg"]];
                    }
                    failure:^(NSError *aError) {
                        
                    }];
                }];
            }else{
                [self shakeWithView:infoView];
                [[HCToast shareInstance] showToast:responseObject[@"msg"]];
            }
        }
        failure:^(NSError *aError) {
            
        }];
    }];
    
    UIPasteboard *pab = [UIPasteboard generalPasteboard];
    if (pab.string.length==5) {
        UIButton *copy = [[UIButton alloc] initWithFrame:CGRectMake(20, _join.maxY+28, infoView.width-40, 20)];
        [copy setImage:[UIImage imageNamed:@"copy"] forState:UIControlStateNormal];
        [copy setTitleColor:GraryHeavyLightColor forState:UIControlStateNormal];
        [copy.titleLabel setFont:DEFAULT_FONT(14)];
        [copy setTitle:@" 粘贴邀请码" forState:UIControlStateNormal];
        copy.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        [scrollView addSubview:copy];
        [[copy rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            self.textField.text = pab.string;
            [self textChangeEvent:self.textField];
            [self.textField resignFirstResponder];
        }];
    }

    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [self insertSubview:bgView atIndex:0];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
    [[tap rac_gestureSignal] subscribeNext:^(id x) {
        [UIView animateWithDuration:0.3 animations:^{
            infoView.y = SCREEN_HEIGHT;
            self.backgroundColor = [RealBlackColor colorWithAlphaComponent:0];
        } completion:^(BOOL finished) {
            [self removeFromSuperview];
        }];
    }];
    [bgView addGestureRecognizer:tap];
    
    [UIView animateWithDuration:0.3 animations:^{
        infoView.y = 178;
        self.backgroundColor = [RealBlackColor colorWithAlphaComponent:0.4];
    }];
}

- (void)shakeWithView:(UIView *)view
{
    UIView *targetView = view ?: self.infoView;
    if (!targetView) return;

    CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.x"];
    shakeAnimation.values = @[@0, @-10, @10, @-10, @10, @-5, @5, @-5, @5, @0];
    shakeAnimation.duration = 0.5;
    shakeAnimation.repeatCount = 1;
    shakeAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    [targetView.layer addAnimation:shakeAnimation forKey:@"shake"];
}

- (void)textChangeEvent:(UITextField *)textField
{
    _textField.text = [_textField.text uppercaseString];
    if (_textField.text.length >= 5){
        _textField.text = [_textField.text substringToIndex:5];
        [((UIButton *)[self viewWithTag:104]) setTitle:[_textField.text substringWithRange:NSMakeRange(4, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:104]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:104].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:103]) setTitle:[_textField.text substringWithRange:NSMakeRange(3, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:103]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:103].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:102]) setTitle:[_textField.text substringWithRange:NSMakeRange(2, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:102]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:102].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:101]) setTitle:[_textField.text substringWithRange:NSMakeRange(1, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:101]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:101].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:100]) setTitle:[_textField.text substringWithRange:NSMakeRange(0, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:100]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:100].backgroundColor = LightBGColor;
        _join.userInteractionEnabled = YES;
        _join.backgroundColor = NormalMainColor;
    }else if (_textField.text.length == 4){
        [((UIButton *)[self viewWithTag:104]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:104]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:104].backgroundColor = NormalMainColor;
        [((UIButton *)[self viewWithTag:103]) setTitle:[_textField.text substringWithRange:NSMakeRange(3, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:103]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:103].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:102]) setTitle:[_textField.text substringWithRange:NSMakeRange(2, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:102]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:102].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:101]) setTitle:[_textField.text substringWithRange:NSMakeRange(1, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:101]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:101].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:100]) setTitle:[_textField.text substringWithRange:NSMakeRange(0, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:100]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:100].backgroundColor = LightBGColor;
        _join.userInteractionEnabled = NO;
        _join.backgroundColor = GraryMiddleColor;
    }else if (_textField.text.length == 3){
        [((UIButton *)[self viewWithTag:104]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:104]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:104].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:103]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:103]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:103].backgroundColor = NormalMainColor;
        [((UIButton *)[self viewWithTag:102]) setTitle:[_textField.text substringWithRange:NSMakeRange(2, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:102]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:102].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:101]) setTitle:[_textField.text substringWithRange:NSMakeRange(1, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:101]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:101].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:100]) setTitle:[_textField.text substringWithRange:NSMakeRange(0, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:100]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:100].backgroundColor = LightBGColor;
        _join.userInteractionEnabled = NO;
        _join.backgroundColor = GraryMiddleColor;
    }else if (_textField.text.length == 2){
        [((UIButton *)[self viewWithTag:104]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:104]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:104].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:103]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:103]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:103].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:102]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:102]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:102].backgroundColor = NormalMainColor;
        [((UIButton *)[self viewWithTag:101]) setTitle:[_textField.text substringWithRange:NSMakeRange(1, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:101]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:101].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:100]) setTitle:[_textField.text substringWithRange:NSMakeRange(0, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:100]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:100].backgroundColor = LightBGColor;
        _join.userInteractionEnabled = NO;
        _join.backgroundColor = GraryMiddleColor;
    }else if (_textField.text.length == 1){
        [((UIButton *)[self viewWithTag:104]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:104]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:104].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:103]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:103]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:103].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:102]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:102]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:102].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:101]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:101]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:101].backgroundColor = NormalMainColor;
        [((UIButton *)[self viewWithTag:100]) setTitle:[_textField.text substringWithRange:NSMakeRange(0, 1)] forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:100]) setTitleColor:NormalMainColor forState:UIControlStateNormal];
        [self viewWithTag:100].backgroundColor = LightBGColor;
        _join.userInteractionEnabled = NO;
        _join.backgroundColor = GraryMiddleColor;
    }else if (_textField.text.length == 0){
        [((UIButton *)[self viewWithTag:104]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:104]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:104].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:103]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:103]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:103].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:102]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:102]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:102].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:101]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:101]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:101].backgroundColor = LightBGColor;
        [((UIButton *)[self viewWithTag:100]) setTitle:@"" forState:UIControlStateNormal];
        [((UIButton *)[self viewWithTag:100]) setTitleColor:RealWhiteColor forState:UIControlStateNormal];
        [self viewWithTag:100].backgroundColor = NormalMainColor;
        _join.userInteractionEnabled = NO;
        _join.backgroundColor = GraryMiddleColor;
    }
}

@end
